<?php
namespace App\Models;

use App\Exceptions\ApiException;
use Illuminate\Support\Facades\DB;

class ManageMessageSend extends CommonModel {
	protected $table = 'manage_message_send';

    /**
     * @param $uid
     * @param $ids
     * @param $village_id
     * 发送内部通知
     */
	public static function send($uid,$content,$ids,$village_id){
	    DB::transaction(function() use($uid,$content,$ids,$village_id){
            $input =[
                'uid'=>$uid,
                'ids'=>$ids,
                'content'=>$content,
                'village_id'=>$village_id
            ];
            $send_id=static::create($input)->id;
            $array = explode(',',$ids);
            foreach($array as $key=>$v) {
                ManageMessage::send($uid, $v->id, $send_id, $village_id,$content);
            }
        });

    }
}